<template>
	<div class="app-container">
		<div class="bgWhite radius8">
			<el-form class="p20 flex col-top row-between" style="padding-bottom: 0;" label-width="100px"
				:model="queryParams" ref="queryForm" :inline="true">
				<div>
					<el-form-item label="关键词" prop="keyword">
						<el-input v-model="queryParams.keyword" placeholder="请输入关键词" clearable class="resetInput"
							style="width: 200px" :suffix-icon="Search" @keyup.enter="handleQuery" />
					</el-form-item>
					<el-form-item label="选择日期" prop="time">
						<el-date-picker style="width: 248px;" 
						v-model="queryParams.time" type="date"
						value-format="YYYY-MM-DD"
						placeholder="请选择日期" size="large"/>
					</el-form-item>
				</div>
				<el-form-item>
					<div class="flex col-center row-end" style="margin-right: 0">
						<el-button class="searchBtn" type="defaultBtn" @click="handleQuery">查询</el-button>
						<el-button class="searchBtn" icon="Refresh" @click="resetQuery">重置</el-button>
					</div>
				</el-form-item>
			</el-form>
		</div>
		<div class="bgWhite radius8 p20 mt25">
			<div class="flex col-center row-between mb20">
				<span class="fb fs16">价格更新列表</span>
			</div>
			<el-table v-loading="loading" :data="list" style="width: 100%" :header-row-style="{
					background: '#FAFAFA',
					color: '#0C1019',
					height: '54px',
				  }" :cell-style="{ height: '54px' }">
				<el-table-column label="价格更新单号" align="center" prop="auditNumber"/>
				<el-table-column label="原材料名称" align="center" prop="materialName"/>
				<el-table-column label="更新时间" align="center" prop="submitterTime"/>
				<el-table-column label="更新人" align="center" prop="submitterName" />
				<el-table-column fixed="right" label="操作" align="center" width="200">
					<template v-slot="scope">
						<el-button size="mini" type="text" @click="handleDetail(scope.row,0)"
						v-if="scope.row.auditOperStatus == 1"
						v-hasPermi="['raw_material_price:updateAuditStatus']"
							>审核</el-button>
						<el-divider v-if="scope.row.auditOperStatus == 1" direction="vertical"></el-divider>	
						<el-button size="mini" type="text" @click="handleDetail(scope.row,1)"
						v-hasPermi="['raw_material_price:auditDetails']"
							>查看详情</el-button>
					</template>
				</el-table-column>
			</el-table>
			<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
								v-model:limit="queryParams.pageSize" @pagination="getList" />
		</div>			
	</div>
</template>

<script setup name="ProductSetup">
	import {
		auditList, //列表
	} from "@/api/business/cost";
	import {
		Search
	} from '@element-plus/icons-vue'
	import {
		getDivisions
	} from "@/api/business/opportunity";//地址
</script>
<script>
	import { getToken } from"@/utils/auth";
	export default {
		data() {
			return {
				loading: true, // 遮罩层
				total: 0, // 总条数
				list: [], // 表格数据
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					keyword: '', // 
					time:''
				}, //查询参数
			}
		},
		created() {
			this.getList()
		},
		methods: {	
			//查询作物列表
			getList() {
				this.loading = true;
				auditList(this.queryParams).then((response) => {
					this.list = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.queryParams.startTime = this.queryParams.time.length > 0 ? this.queryParams.time[0]+' '+'00:00:00' : ''
				this.queryParams.endTime = this.queryParams.time.length > 0 ? this.queryParams.time[1]+' '+'23:59:59' : ''
				this.getList();
			},
			/** 重置按钮操作 */
			resetQuery() {
				this.resetForm("queryForm");
				this.handleQuery();
			},
			// 详情
			handleDetail(row,num) {
				this.$router.push('/cost/examineDetail?id=' + row.id+'&type='+num)
			},
		}
	}
</script>